/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.service.impl;

import com.click.app.dao.CartDao;
import com.click.app.model.Cart;
import com.click.app.model.Product;
import com.click.app.model.User;
import com.click.app.service.CartManager;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author arnold
 */
public class CartManagerImpl extends GenericManagerImpl<Cart, Long> implements CartManager {

    CartDao cartDao;

    public CartManagerImpl(CartDao cartDao) {
        super(cartDao);
        this.cartDao = cartDao;
    }
    public List<Cart> findById(Long id) {
        return cartDao.findById(id);
    }

    public CartDao getCartDao() {
        return cartDao;
    }

    public void setCartDao(CartDao cartDao) {
        this.cartDao = cartDao;
    }
    public List<Cart> findCartByProduct(Product product){
        return cartDao.findCartByProduct(product);
    }
    public List<Cart> findCartByUser(User user){
        return cartDao.findCartByUser(user);
    }

    public List<Cart> findAllIds(List<Long> listIds){
        List<Cart> res = new ArrayList<Cart>();
        for (Iterator<Long> it = listIds.iterator(); it.hasNext();) {
            Long idLong = it.next();
            Cart mat = this.get(idLong);
            if(mat!=null)
                res.add(mat);
        }
        return res;
    }


}

